package com.smartleanx.module.hrm.service.salary;


import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.smartleanx.module.hrm.dal.dataobject.salary.HrmSalaryStandard;
import com.smartleanx.module.hrm.dal.mysql.salary.HrmSalaryStandardMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mybatis-plus
 * @since 2025-01-06
 */
@Service
public class HrmSalaryStandardServiceImpl  implements HrmSalaryStandardService {



    @Autowired
    private HrmSalaryStandardMapper hrmSalaryStandardMapper;
    @Override
    public void insertSalaryStandard(HrmSalaryStandard salaryStandard) {
        hrmSalaryStandardMapper.insert(salaryStandard);
    }


    @Override
    public void updateSalaryStandard(HrmSalaryStandard salaryStandard) {
        hrmSalaryStandardMapper.updateById(salaryStandard);
    }


    @Override
    public PageInfo<HrmSalaryStandard> selectSalaryStandardByPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<HrmSalaryStandard> hrmSalaryStandards = hrmSalaryStandardMapper.selectList(null);
        return new PageInfo<>(hrmSalaryStandards);
    }


    @Override
    public List<JSONObject> salaryStandardBySelect() {
        List<JSONObject> resultList=new ArrayList<>();
        List<HrmSalaryStandard> hrmSalaryStandards = hrmSalaryStandardMapper.selectList(null);
        hrmSalaryStandards.forEach(hrmSalaryStandard -> {
            JSONObject result=new JSONObject();
            result.put("id",hrmSalaryStandard.getId());
            result.put("value",hrmSalaryStandard.getValue());
               resultList.add(result);
        });
        return resultList;
    }
}
